package core;

import org.easyway.collisions.GroupCollision;
import org.easyway.interfaces.extended.ILoopable;
import org.easyway.objects.sprites2D.Mask;
import org.easyway.objects.sprites2D.SpriteColl;
import org.easyway.objects.texture.Texture;
import org.easyway.system.StaticRef;

@SuppressWarnings("serial")
public class Enemy extends SpriteColl implements ILoopable {

	protected static Texture image;
	private float speed = 3.0f;
	
	public Enemy(float x, float y) {
		super(x, y, image);
		GroupCollision group = GroupCollision.getGroup("myGroup");
		group.destination.add(this);
	}
	
	public static void init() {
		if (image!=null) {
			// textures are already initialized!
			return;
		}
		// loads the texture
		image = new Texture("images/enemy.png",255,255,255);
		new Mask(image);
	}
	
	public void onCollision() {
		destroy();
	}

	public void loop() {
		incY(speed );
		if (getY() > StaticRef.getCamera().getHeight()) {
			setY(-getHeight());
		}
	}
}
